from sys import stderr

"""
自定义断言库，需要其它断言可自行扩充，并定义为静态方法
"""

__author__ = "冰点契约"


class Assert:
    @staticmethod
    def assert_equals(expected, actual, fullback=None) -> None:
        try:
            assert expected == actual
        except AssertionError as e:
            stderr.write(f"assert filed. expected:{expected}  actual:{actual}\n")
            if fullback:
                fullback()

    @staticmethod
    def assert_is_empty(expected, fullback=None) -> None:
        try:
            if isinstance(expected, str):
                assert len(expected) == 0
            else:
                assert expected is None
        except AssertionError as e:
            stderr.write(f"assert filed. target:{expected} not is empty\n")
            if fullback:
                fullback()
